<template>
  <div class="comment">
    <div class="com_box">
      <div class="com_box_title">课程列表<img src="https://o6wndwjxn.qnssl.com/close.png" @click="com_box_close_click"></div>
      <div class="com_box_list">
        <div
          class="com_box_list_item"
          v-for="(item,index) in type"
          :key='index'
          @click="com_box_click(index,item.chapter_id)"
        >
          <div :class="item.status ?  'selected' :''">{{item.title}}</div>
          <div><img
              v-if="item.status"
              src="https://o6wndwjxn.qnssl.com/%E8%AF%BE%E7%A8%8B%E5%88%97%E8%A1%A8-%E9%80%89%E4%B8%AD@3x.png"
              alt=""
            ></div>
        </div>
      </div>
      <!-- <div
        class="com_box_close"
        @click="com_box_close_click()"
      >取消</div> -->
    </div>
  </div>
</template>

<script>
export default {
  props: {
    type: Array,
    c: [String, Number]
  },
  data () {
    return {
      comment_son_status: 1,
      comment_son_zid: []
    }
  },
  created () {
    console.log('试听课', this.type)
  },
  methods: {
    com_box_click (e, z) {
      // for (var i = 0; i < this.type.length; i++) {
      //   if (this.type[e].audition == 2) {
      //     this.$emit('PurStatus')
      //     // console.log('购买')
      //     return
      //   }
      // }
      this.comment_son_zid[0] = e
      this.comment_son_zid[1] = z
      for (var i = 0; i < this.type.length; i++) {
        this.type[i].status = false
        this.type[e].status = true
      }
      this.$emit('CommentZid', this.comment_son_zid)
    },
    com_box_close_click () {
      this.$emit('CommentStatus', this.comment_son_status)
    }
  }
}
</script>

<style>
.com_box {
  position: fixed;
  left: 0;
  bottom: 0;
  border-radius: 10px 10px 0 0;
  width: 100vw;
  height: 60vh;
  background: white;
}
.com_box_title {
  width: 100vw;
  text-align: center;
  height: 55px;
  line-height: 55px;
  font-size: 18px;
  color: #1a1a1a;
  font-weight: bold;
  position: relative;
}
.com_box_list {
  width: 100vw;
  height: calc(60vh - 55px);
  overflow: scroll;
}
.com_box_close {
  border-top: 1px solid #f4f4f4;
  height: 50px;
  line-height: 50px;
  font-size: 15px;
  color: #1a1a1a;
  text-align: center;
}
.com_box_list_item {
  height: 55px;
  line-height: 55px;
  font-size: 14px;
  color: #1a1a1a;
  font-weight: bold;
  display: flex;
  padding: 0 20px;
}
.com_box_list_item > div:nth-child(1) {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.com_box_list_item > div:nth-child(2) {
  width: 80px;
  position: relative;
}
.com_box_list_item > div:nth-child(2) img {
  position: absolute;
  top: 19px;
  right: 0;
  width: 13px;
  height: 15px;
}
.selected {
  font-family: PingFangSC-Semibold;
  color: #da4131;
}
.com_box_title > img {
  width: 10px;
  height: 10px;
  position: absolute;
  top: 50%;
  transform: translate(0, -50%);
  right: 5vw;
}
</style>
